package com.freemarker.demo.service;

import com.freemarker.demo.dao.CategoryMapper;
import com.freemarker.demo.pojo.Category;
import com.freemarker.demo.utils.ServerResponse;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @CLASSNAME CategoryService
 * @DESCRIPTION 描述
 * @AUTHOR chen
 * @DATE 2019-03-22 14:38
 **/

@Service
@Slf4j
public class CategoryService {

    @Resource
    private CategoryMapper categoryMapper;

    public ServerResponse listPage(Integer pn, Integer pageSize) {
        PageHelper.startPage( pn, pageSize );
        List <Category> categoryList = categoryMapper.selectByExample( null );
        PageInfo p = new PageInfo( categoryList );
        return ServerResponse.createBySuccess( p );
    }
}
